package com.buba.springboot.utils;

import lombok.Data;

@Data
public class CommonResult {
    private int code =200;

    private boolean flag=true;

    private Object obj;

    public static CommonResult ok(){return ok(null);}

    public static CommonResult ok(Object obj){
        CommonResult commonResult =new CommonResult();
        commonResult.setObj(obj);
        return commonResult;
    }

    public static CommonResult fail(){return fail(null);}

    public static CommonResult fail(Object obj){
        CommonResult commonResult =new CommonResult();
        commonResult.setFlag(false);
        commonResult.setObj(obj);
        return commonResult;
    }

    public static CommonResult fail(int code,Object obj){
        CommonResult commonResult = new CommonResult();
        commonResult.setCode(code);
        commonResult.setFlag(false);
        commonResult.setObj(obj);
        return commonResult;
    }
}
